package 模拟;

/**
 * @author mubei
 * @date 2021/12/21
 * @description
 */
public class Demo01数字序列中某一位的数字 {

    public static void main(String[] args) {
        find(1000);
    }

    public static int find(int n){
        if(n<10){
            return n;
        }
        n--;
        int k = 1;
        int num = 0;
        while(n>0) {
            num = n;
            //
            n = (int)(n - Math.pow(10,k-1)*9*k);
            k++;
        }
        int a = num/(k-1);
        int b = num % (k-1);
        String s = a+"";
        return Integer.parseInt(s.substring(b,b+1));
    }


}
